package com.rajaev.dtu.tractor.infrastructure.base.enums;

import cn.hutool.core.util.EnumUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.EnumUtils;

import java.util.Map;
import java.util.Optional;

/**
 * @Created with IDEA
 * @author: tianjie
 * @Date:2019/7/9
 * @Time:17:25
 */
public enum BatteryWorkStateEnum {
    /**
     * 离线
     */
    OFFLINE("0"),

    /**
     * 放电
     */
    DISCHARGE("1"),

    /**
     * 待机
     */
    AWAIT("2"),

    /**
     * 充电
     */
    CHARGE("3"),
    /**
     * 紧急模式
     */
    EMERGENT("4");

    private String state;

    BatteryWorkStateEnum(String state) {
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public boolean equals(String state){
        if(this.state.equalsIgnoreCase(state)){
            return true;
        }else {
            return false;
        }
    }

    public static Optional<BatteryWorkStateEnum> stateOf(String state){
        BatteryWorkStateEnum[] batteryWorkStateEnums = BatteryWorkStateEnum.values();
        for (BatteryWorkStateEnum batteryWorkStateEnum : batteryWorkStateEnums) {
            if(batteryWorkStateEnum.getState().equals(state)){
                return Optional.of(batteryWorkStateEnum);
            }
        }
        return Optional.empty();
    }

}
